package com.knowledge.business.controller;


import java.util.Arrays;
import java.util.List;

import com.knowledge.common.annotation.Log;
import com.knowledge.common.core.controller.BaseController;
import com.knowledge.common.core.domain.AjaxResult;
import com.knowledge.common.enums.BusinessType;
import com.knowledge.common.utils.poi.ExcelUtil;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.knowledge.business.domain.LllmSysConfig;
import com.knowledge.business.service.LllmISysConfigService;
import com.knowledge.common.core.page.TableDataInfo;

/**
 * 模型配置(模型、语音识别、语音合成等)Controller
 *
 * @author zhaoyk
 * @date 2025-09-15
 */
@RestController
@RequestMapping("/business/LllmConfig")
public class LllmSysConfigController extends BaseController {
    @Autowired
    private LllmISysConfigService sysConfigService;

    /**
     * 查询模型配置(模型、语音识别、语音合成等)列表
     */
//@RequiresPermissions("business:LllmConfig:list")
    @GetMapping("/list")
    public TableDataInfo list(LllmSysConfig lllmSysConfig) {
        startPage();
        List<LllmSysConfig> list = sysConfigService.selectSysConfigList(lllmSysConfig);
        return getDataTable(list);
    }


    @GetMapping("/alllist")
    public AjaxResult alllist(LllmSysConfig lllmSysConfig) {
        List<LllmSysConfig> list = sysConfigService.selectSysConfigList(lllmSysConfig);
        return AjaxResult.success(list);
    }

    /**
     * 导出模型配置(模型、语音识别、语音合成等)列表
     */
    //@RequiresPermissions("business:LllmConfig:export")
    @Log(title = "模型配置(模型、语音识别、语音合成等)", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LllmSysConfig lllmSysConfig) {
        List<LllmSysConfig> list = sysConfigService.selectSysConfigList(lllmSysConfig);
        ExcelUtil<LllmSysConfig> util = new ExcelUtil<LllmSysConfig>(LllmSysConfig.class);
        util.exportExcel(response, list, "模型配置(模型、语音识别、语音合成等)数据");
    }

    /**
     * 获取模型配置(模型、语音识别、语音合成等)详细信息
     */
    //@RequiresPermissions("business:LllmConfig:query")
    @GetMapping(value = "/{configId}")
    public AjaxResult getInfo(@PathVariable("configId") String configId) {
        return AjaxResult.success(sysConfigService.selectSysConfigByConfigId(configId));
    }

    /**
     * 新增模型配置(模型、语音识别、语音合成等)
     */
    //@RequiresPermissions("business:LllmConfig:add")
    @Log(title = "模型配置(模型、语音识别、语音合成等)", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LllmSysConfig lllmSysConfig) {
        return toAjax(sysConfigService.save(lllmSysConfig));
    }

    /**
     * 修改模型配置(模型、语音识别、语音合成等)
     */
    //@RequiresPermissions("business:LllmConfig:edit")
    @Log(title = "模型配置(模型、语音识别、语音合成等)", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LllmSysConfig lllmSysConfig) {
        return toAjax(sysConfigService.updateSysConfig(lllmSysConfig));
    }

    /**
     * 删除模型配置(模型、语音识别、语音合成等)
     */
    //@RequiresPermissions("business:LllmConfig:remove")
    @Log(title = "模型配置(模型、语音识别、语音合成等)", businessType = BusinessType.DELETE)
    @DeleteMapping("/{configIds}")
    public AjaxResult remove(@PathVariable String[] configIds) {
        return toAjax(sysConfigService.deleteSysConfigByConfigIds(configIds));
    }
}
